<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Question extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_IdQuestion;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_SondageIdsondage;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_TypequestionIdtypequestion;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Textquestion;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Description;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Ordrequestion;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Score;


    /**
     * Parent relation fk_Question_typequestion1
     *
     * @var Application_Model_Typequestion
     */
    protected $_Typequestion;

    /**
     * Parent relation fk_Question_sondage1
     *
     * @var Application_Model_Sondage
     */
    protected $_Sondage;


    /**
     * Dependent relation fk_listesreponse_Question1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Listesreponse
     */
    protected $_Listesreponse;

    /**
     * Dependent relation fk_reponse_Question1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Reponse
     */
    protected $_Reponse;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idQuestion'=>'IdQuestion',
            'sondage_idsondage'=>'SondageIdsondage',
            'typequestion_idtypequestion'=>'TypequestionIdtypequestion',
            'textquestion'=>'Textquestion',
            'description'=>'Description',
            'ordrequestion'=>'Ordrequestion',
            'score'=>'Score',
        ));

        $this->setParentList(array(
            'FkQuestionTypequestion1'=> array(
                    'property' => 'Typequestion',
                    'table_name' => 'Typequestion',
                ),
            'FkQuestionSondage1'=> array(
                    'property' => 'Sondage',
                    'table_name' => 'Sondage',
                ),
        ));

        $this->setDependentList(array(
            'FkListesreponseQuestion1' => array(
                    'property' => 'Listesreponse',
                    'table_name' => 'Listesreponse',
                ),
            'FkReponseQuestion1' => array(
                    'property' => 'Reponse',
                    'table_name' => 'Reponse',
                ),
        ));
    }

    /**
     * Sets column idQuestion
     *
     * @param int $data
     * @return Application_Model_Question
     */
    public function setIdQuestion($data)
    {
        $this->_IdQuestion = $data;
        return $this;
    }

    /**
     * Gets column idQuestion
     *
     * @return int
     */
    public function getIdQuestion()
    {
        return $this->_IdQuestion;
    }

    /**
     * Sets column sondage_idsondage
     *
     * @param int $data
     * @return Application_Model_Question
     */
    public function setSondageIdsondage($data)
    {
        $this->_SondageIdsondage = $data;
        return $this;
    }

    /**
     * Gets column sondage_idsondage
     *
     * @return int
     */
    public function getSondageIdsondage()
    {
        return $this->_SondageIdsondage;
    }

    /**
     * Sets column typequestion_idtypequestion
     *
     * @param string $data
     * @return Application_Model_Question
     */
    public function setTypequestionIdtypequestion($data)
    {
        $this->_TypequestionIdtypequestion = $data;
        return $this;
    }

    /**
     * Gets column typequestion_idtypequestion
     *
     * @return string
     */
    public function getTypequestionIdtypequestion()
    {
        return $this->_TypequestionIdtypequestion;
    }

    /**
     * Sets column textquestion
     *
     * @param text $data
     * @return Application_Model_Question
     */
    public function setTextquestion($data)
    {
        $this->_Textquestion = $data;
        return $this;
    }

    /**
     * Gets column textquestion
     *
     * @return text
     */
    public function getTextquestion()
    {
        return $this->_Textquestion;
    }

    /**
     * Sets column description
     *
     * @param text $data
     * @return Application_Model_Question
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets column ordrequestion
     *
     * @param int $data
     * @return Application_Model_Question
     */
    public function setOrdrequestion($data)
    {
        $this->_Ordrequestion = $data;
        return $this;
    }

    /**
     * Gets column ordrequestion
     *
     * @return int
     */
    public function getOrdrequestion()
    {
        return $this->_Ordrequestion;
    }

    /**
     * Sets column score
     *
     * @param int $data
     * @return Application_Model_Question
     */
    public function setScore($data)
    {
        $this->_Score = $data;
        return $this;
    }

    /**
     * Gets column score
     *
     * @return int
     */
    public function getScore()
    {
        return $this->_Score;
    }

    /**
     * Sets parent relation TypequestionIdtypequestion
     *
     * @param Application_Model_Typequestion $data
     * @return Application_Model_Question
     */
    public function setTypequestion(Application_Model_Typequestion $data)
    {
        $this->_Typequestion = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idtypequestion'];
        }

        $this->setTypequestionIdtypequestion($primary_key);

        return $this;
    }

    /**
     * Gets parent TypequestionIdtypequestion
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Typequestion
     */
    public function getTypequestion($load = true)
    {
        if ($this->_Typequestion === null && $load) {
            $this->getMapper()->loadRelated('FkQuestionTypequestion1', $this);
        }

        return $this->_Typequestion;
    }

    /**
     * Sets parent relation SondageIdsondage
     *
     * @param Application_Model_Sondage $data
     * @return Application_Model_Question
     */
    public function setSondage(Application_Model_Sondage $data)
    {
        $this->_Sondage = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idsondage'];
        }

        $this->setSondageIdsondage($primary_key);

        return $this;
    }

    /**
     * Gets parent SondageIdsondage
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sondage
     */
    public function getSondage($load = true)
    {
        if ($this->_Sondage === null && $load) {
            $this->getMapper()->loadRelated('FkQuestionSondage1', $this);
        }

        return $this->_Sondage;
    }

    /**
     * Sets dependent relations fk_listesreponse_Question1
     *
     * @param array $data An array of Application_Model_Listesreponse
     * @return Application_Model_Question
     */
    public function setListesreponse(array $data)
    {
        $this->_Listesreponse = array();

        foreach ($data as $object) {
            $this->addListesreponse($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_listesreponse_Question1
     *
     * @param Application_Model_Listesreponse $data
     * @return Application_Model_Question
     */
    public function addListesreponse(Application_Model_Listesreponse $data)
    {
        $this->_Listesreponse[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_listesreponse_Question1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Listesreponse
     */
    public function getListesreponse($load = true)
    {
        if ($this->_Listesreponse === null && $load) {
            $this->getMapper()->loadRelated('FkListesreponseQuestion1', $this);
        }

        return $this->_Listesreponse;
    }

    /**
     * Sets dependent relations fk_reponse_Question1
     *
     * @param array $data An array of Application_Model_Reponse
     * @return Application_Model_Question
     */
    public function setReponse(array $data)
    {
        $this->_Reponse = array();

        foreach ($data as $object) {
            $this->addReponse($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_reponse_Question1
     *
     * @param Application_Model_Reponse $data
     * @return Application_Model_Question
     */
    public function addReponse(Application_Model_Reponse $data)
    {
        $this->_Reponse[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_reponse_Question1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Reponse
     */
    public function getReponse($load = true)
    {
        if ($this->_Reponse === null && $load) {
            $this->getMapper()->loadRelated('FkReponseQuestion1', $this);
        }

        return $this->_Reponse;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Question
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Question());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Question::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdQuestion() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idQuestion = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdQuestion()));
    }
}
